package com.onpositive.gamemaker.spriteeditor;

import org.eclipse.swt.graphics.Rectangle;

/**
 * Sprite descriptor
 * @author 32kda
 *
 */
public class SpriteDescriptor
{
	protected String type;
	protected String fileName;
	protected int x;
	protected int y;
	protected int width = 0;
	protected int height = 0;
	protected int xoffset = 0;
	protected int yoffset = 0;
	
	public SpriteDescriptor(String type, String fileName)
	{
		super();
		this.type = type;
		this.fileName = fileName;
	}

	public SpriteDescriptor(String type, java.lang.String fileName, int x, int y, int width, int height, int xoffset, int yoffset)
	{
		super();
		this.type = type;
		this.fileName = fileName;
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
		this.xoffset = xoffset;
		this.yoffset = yoffset;
	}
	
	public SpriteDescriptor(String type, String fileName, int x, int y, int width, int height)
	{
		this(type, fileName, x, y, width, height, 0, 0);
	}

	public void setBounds(int x, int y, int width, int height)
	{
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
	}

	/**
	 * @return the type
	 */
	public String getType()
	{
		return type;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(String type)
	{
		this.type = type;
	}

	/**
	 * @return the fileName
	 */
	public String getFileName()
	{
		return fileName;
	}

	/**
	 * @param fileName the fileName to set
	 */
	public void setFileName(String fileName)
	{
		this.fileName = fileName;
	}

	/**
	 * @return the x
	 */
	public int getX()
	{
		return x;
	}

	/**
	 * @param x the x to set
	 */
	public void setX(int x)
	{
		this.x = x;
	}

	/**
	 * @return the y
	 */
	public int getY()
	{
		return y;
	}

	/**
	 * @param y the y to set
	 */
	public void setY(int y)
	{
		this.y = y;
	}

	/**
	 * @return the width
	 */
	public int getWidth()
	{
		return width;
	}

	/**
	 * @param width the width to set
	 */
	public void setWidth(int width)
	{
		this.width = width;
	}

	/**
	 * @return the height
	 */
	public int getHeight()
	{
		return height;
	}

	/**
	 * @param height the height to set
	 */
	public void setHeight(int height)
	{
		this.height = height;
	}

	/**
	 * @return the xoffset
	 */
	public int getXoffset()
	{
		return xoffset;
	}

	/**
	 * @param xoffset the xoffset to set
	 */
	public void setXoffset(int xoffset)
	{
		this.xoffset = xoffset;
	}

	/**
	 * @return the yoffset
	 */
	public int getYoffset()
	{
		return yoffset;
	}

	/**
	 * @param yoffset the yoffset to set
	 */
	public void setYoffset(int yoffset)
	{
		this.yoffset = yoffset;
	}
	
	public void setOffsets(int xoffset, int yoffset)
	{
		this.xoffset = xoffset;
		this.yoffset = yoffset;
	}
	
	public String getId()
	{
		if (width == 0)
			return fileName;
		return fileName + "["+x+","+y+","+width+","+height+"]";
	}
	
	public Rectangle getBounds()
	{
		return new Rectangle(x,y,width,height);
		
	}
}
